package com.swang.pms.service.common.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.swang.pms.dal.common.SysUrlWhiteListDao;
import com.swang.pms.model.common.GridUtil;
import com.swang.pms.model.common.Pager;
import com.swang.pms.model.dto.common.SysUrlWhiteListDto;
import com.swang.pms.service.common.SysUrlWhiteListService;

/**
 * @ClassName: SysUrlWhiteListServiceImpl
 * @Description: 白名单
 * @author 王泽
 * @date 2017年3月16日 下午9:45:51
 */
@Service("sysUrlWhiteListService")
public class SysUrlWhiteListServiceImpl implements SysUrlWhiteListService {

    @Resource
    private SysUrlWhiteListDao sysUrlWhiteListDao;

    @Override
    public Boolean deleteByPrimaryKey(SysUrlWhiteListDto record) {
        return sysUrlWhiteListDao.deleteByPrimaryKey(record.getId()) == 1;
    }

    @Override
    public Boolean insertSelective(SysUrlWhiteListDto record) {
        return sysUrlWhiteListDao.insertSelective(record) == 1;
    }

    @Override
    public Boolean updateByPrimaryKeySelective(SysUrlWhiteListDto record) {
        return sysUrlWhiteListDao.updateByPrimaryKeySelective(record) == 1;
    }

    @Override
    public Pager findPageDataHosUrlsDto(Pager page, SysUrlWhiteListDto dto) {
        String[] paramSerial = new String[] { "id", "app_id", "sys_type", "url", "remark", "gmt_modify", "operator" };
        dto.setStartIndex(page.getRowStartIndex());
        dto.setPageSize(page.getPageSize());
        List<Map<String, Object>> list = sysUrlWhiteListDao.findPageDataHosUrlsDto(dto);
        dto.setStartIndex(null);
        dto.setPageSize(null);
        page.setRowCount(sysUrlWhiteListDao.findPageDataCountByDto(dto));
        page.setGridr(GridUtil.getGridList(list, paramSerial, page.getRowStartIndex(), page.getPageSize(), page.getRowCount(), true));
        return page;
    }

    @Override
    public Pager findPageDataSvUrlsByDto(Pager page, SysUrlWhiteListDto dto) {
        String[] paramSerial = new String[] { "id", "app_id", "app_name", "url", "remark", "gmt_modify", "operator" };
        dto.setStartIndex(page.getRowStartIndex());
        dto.setPageSize(page.getPageSize());
        List<Map<String, Object>> list = sysUrlWhiteListDao.findPageDataSvUrlsByDto(dto);
        dto.setStartIndex(null);
        dto.setPageSize(null);
        page.setRowCount(sysUrlWhiteListDao.findPageDataCountByDto(dto));
        page.setGridr(GridUtil.getGridList(list, paramSerial, page.getRowStartIndex(), page.getPageSize(), page.getRowCount(), true));
        return page;
    }

    @Override
    public int findPageDataCountByDto(SysUrlWhiteListDto dto) {
        return sysUrlWhiteListDao.findPageDataCountByDto(dto);
    }

    @Override
    public List<SysUrlWhiteListDto> selectsBySelf(SysUrlWhiteListDto dto) {
        return sysUrlWhiteListDao.selectsBySelf(dto);
    }
}
